/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.lucava.boatskeeper.client;

import com.google.gwt.user.client.ui.DecoratorPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 *
 * @author glenn
 */
public class MainMenu extends VerticalPanel {

    public MainMenu() {
        super();
        add(getAccountMenu());
        add(getBoatMenu());
        add(getUserMenu());
    }

    private DecoratorPanel getAccountMenu() {

        VerticalPanel panel = new VerticalPanel();
        panel.setWidth("100%");

        panel.add(new HTML("<h1>Mon Compte</h1>"));

        Hyperlink linkEdit = new Hyperlink();
        linkEdit.setText("Modifier");

        Image imageEdit = new Image("");
        linkEdit.getElement().getFirstChild().appendChild(imageEdit.getElement());

        Hyperlink linkDiscon = new Hyperlink();
        linkDiscon.setText("Se déconnecter");
        Image imageDiscon = new Image("");
        linkDiscon.getElement().getFirstChild().appendChild(imageDiscon.getElement());

        panel.add(linkEdit);
        panel.add(linkDiscon);

        DecoratorPanel deco = new DecoratorPanel();

        deco.add(panel);
        return deco;
    }

    private DecoratorPanel getBoatMenu() {
        VerticalPanel panel = new VerticalPanel();
        panel.setWidth("100%");

        panel.add(new HTML("<h1>Gestion des bateaux</h1>"));

        Hyperlink linkBoats = new Hyperlink();
        linkBoats.setText("Voir tous les bateaux");
        linkBoats.setTargetHistoryToken(PlaceMapper.LIST_BOAT.getId());

        Image imageBoats = new Image("");
        linkBoats.getElement().getFirstChild().appendChild(imageBoats.getElement());

        Hyperlink linkMyBoats = new Hyperlink();
        linkMyBoats.setText("Voir mes bateaux");
        Image imageMyBoats = new Image("");
        linkMyBoats.getElement().getFirstChild().appendChild(imageMyBoats.getElement());

        Hyperlink linkAddBoat = new Hyperlink();
        linkAddBoat.setText("Ajouter un bateau");
        linkAddBoat.setTargetHistoryToken(PlaceMapper.EDIT_BOAT.getId());

        Hyperlink linkAddCat = new Hyperlink();
        linkAddCat.setText("Ajouter une catégorie");
        linkAddCat.setTargetHistoryToken("");


        Image imageAddCat = new Image("");
        linkAddCat.getElement().getFirstChild().appendChild(imageAddCat.getElement());

        panel.add(linkBoats);
        panel.add(linkMyBoats);
        panel.add(linkAddBoat);
        panel.add(linkAddCat);

        DecoratorPanel deco = new DecoratorPanel();
        deco.add(panel);
        return deco;

    }

    private DecoratorPanel getUserMenu() {
        VerticalPanel panel = new VerticalPanel();
        panel.setWidth("100%");

        panel.add(new HTML("<h1>Gestion des users</h1>"));

        Hyperlink linkUsers = new Hyperlink();
        linkUsers.setText("Voir tous les utilisteurs");
        linkUsers.setTargetHistoryToken(PlaceMapper.LIST_USER.getId());

        Image imageUsers = new Image("");
        linkUsers.getElement().getFirstChild().appendChild(imageUsers.getElement());

        Hyperlink linkAddUser = new Hyperlink();
        linkAddUser.setText("Ajouter un utilisteur");
        linkAddUser.setTargetHistoryToken(PlaceMapper.EDIT_USER.getId());
        Image imageAddUser = new Image("");
        linkAddUser.getElement().getFirstChild().appendChild(imageAddUser.getElement());


        panel.add(linkUsers);
        panel.add(linkAddUser);

        DecoratorPanel deco = new DecoratorPanel();
        deco.add(panel);
        return deco;
    }
}
